package com.xiaoma.singleton;

import com.xiaoma.singleton.demo.President;

/**
 * @description  单例测试类
 * @author wangtianxiang
 * @date: 2021/3/17 14:30
 */
public class SingletonTest {

    public static void main(String[] args) {
        /*LazySingleton instance1 = LazySingleton.getInstance();
        LazySingleton instance2 = LazySingleton.getInstance();*/
/*        HungrySingleton instance1 = HungrySingleton.getInstance();
        HungrySingleton instance2 = HungrySingleton.getInstance();*/
//        System.out.println(instance1 == instance2);
        President zt1 = President.getInstance();
        zt1.getName();
        President zt2 = President.getInstance();
        zt2.getName();
        if(zt1 == zt2){
            System.out.println("他们是同一人");
        }else{
            System.out.println("他们不是同一人");
        }
    }
}
